#include "../include/head.h"
#include "../include/taskQueue.h"

/* Usage*/
//尾插头删

int taskQueueInit(taskQueue_t *pqueue)
{
    bzero(pqueue,sizeof(taskQueue_t));
    return 0;
}
int tail_insert(taskQueue_t *pqueue,int netfd)
{
    
    node_t *pNew = (node_t *)calloc(1,sizeof(node_t));
    pNew->netfd = netfd;
    
    if(pqueue->size == 0)
    { 
        pqueue->phead = pNew;
        pqueue->ptail = pNew;
    }
    else
    { 
        pqueue->ptail->pnext = pNew;
        pqueue->ptail = pNew;
    }
    pqueue->size++;
    return 0;
}
int head_dele(taskQueue_t *pqueue)
{ 
    node_t *pCur = pqueue->phead;
    pqueue->phead = pCur->pnext;

    if(pqueue->size == 1)
    {
        pqueue->ptail = NULL;
    }
    free(pCur);
    pqueue->size--;
    
    return 0;
}

